package cn.sunxyz.struct.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yangrd on 2017/5/13.
 */
public class GenderFactory {
    private static GenderFactory genderFactory = new GenderFactory();
    private static Map<String, Gender> genderMap;

    private GenderFactory() {
        genderMap = new HashMap<>();
        genderMap.put("W",new WoMan());
        genderMap.put("M",new Man());
    }

    public static GenderFactory getGenderFactory() {
        return genderFactory;
    }

    public  Gender gender(String gender) {
        return genderMap.get(gender);
    }
}
